//
//  CUploadPageCtrl.h
//  HCHK_iphone
//
//  Created by yilong zhang on 11-12-19.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import "CRootCtrlManager.h"
#import "CameraViewController.h"
#import "PhotosViewController.h"
#import "CUploadView.h"
#import "CUploadEditView.h"
#import "CAddressListView.h"
#import "CTopBarView.h"
#import "CDraftList.h"


@protocol UploadViewDelegate;
@protocol UploadEditViewDelegate;
@protocol AddressListDelegate;
@protocol DraftListDelegate;
@protocol PhotoImagePickerDelegate;
@protocol CameraImagePickerDelegate;

@class CProduct;
@class CAddressListView;
@class CAddr;
@class CResInfo;
@class CUploadView;
@class CUploadEditView;
@class CDraftList;

//===========================================================================================================================

@interface CUploadPageCtrl : UIViewController <UIAlertViewDelegate, UploadViewDelegate, TopBarDelegate, UploadEditViewDelegate, SinaWeiboDelegate, QQWeiboDelegate, RenRenDelegate, AddressListDelegate, UIActionSheetDelegate, DraftListDelegate, OperationDelegate, PhotoImagePickerDelegate, CameraImagePickerDelegate>

@property (nonatomic, assign) CameraViewController  *m_Camera;
@property (nonatomic, assign) PhotosViewController  *m_Photo;
@property (nonatomic, retain) UIImageView           *m_PreView;
@property (nonatomic, retain) NSString              *m_strMainImg;
@property (nonatomic, assign) NSMutableArray        *m_ImgPathes;

//topbar
@property (nonatomic, assign) CTopBarView   *m_TopBar;

@property (nonatomic, assign) BOOL          m_bIsSketch;

@property (nonatomic, assign) UILabel       *m_CameraLoading;

//uploadview
@property (nonatomic, assign) CUploadView   *m_UploadView;
@property (nonatomic, assign) CProduct      *m_Product;

//uploadeditview
@property (nonatomic, assign) CUploadEditView   *m_EditView;

//address list
@property (nonatomic, assign) CAddressListView  *m_AddrLst;

//draft list
@property (nonatomic, assign) CDraftList    *m_DraftLst;

//state
@property (nonatomic, assign) int   m_nState;

//activesheet
@property (nonatomic, assign) UIActionSheet *m_Sheet;

+(CUploadPageCtrl*)DefaultUploadPage;
+(void)DestroyUploadPage;

-(void)Photograph;
-(void)DidPhotograph:(UIImage*)image;

-(void)CommitUploadImage:(int)width Height:(int)height Data:(NSData*)data;
-(void)UploadImageResult:(NSNotification*)ret;
-(void)CommitUploadProduct:(NSString*)ImgPath;
-(void)UploadProductResult:(NSNotification*)ret;

-(void)CommitUploadDraftImage:(int)width Height:(int)height Data:(NSData*)data;
-(void)UploadImageDraftResult:(NSNotification*)ret;
-(void)CommitUploadDraftProduct:(NSString*)ImgPath;
-(void)UploadProductDraftResult:(NSNotification*)ret;

-(UIImage*)CompressImage:(CGSize)newSize Image:(UIImage*)image;

-(void)RequestError:(NSNotification*)mes;
-(void)RequestTimeOut:(NSNotification*)mes;

//uploadview
-(void)ShowUploadView:(UIImage*)image;
-(void)DidUploadViewShown;
-(void)HiddenUploadView;
-(void)DidUploadViewHidden;
-(void)SetUploadView;

//addresslistview
-(void)ShowAddressList;
-(void)DidShowAddressList;
-(void)HiddenAddressList;
-(void)DidHiddenAddressList;

//draft list
-(void)ShowDraftList;
-(void)DidShowDraftList;
-(void)HiddenDraftList;
-(void)DidHiddenDraftList;

-(void)PubTheDraft:(CDraft*)draft;
-(void)SynDraftToServer:(CDraft*)draft;
-(void)CancelDrafts:(NSArray*)drafts;

//editview
-(void)ShowEditView;
-(void)DidEditViewShown;
-(void)HiddenEditView:(int)state;
-(void)DidEditViewHidden:(NSNumber*)state;

//share
-(void)ShareFood;
-(void)ShareToSina;
-(void)ShareToTx;
-(void)ShareToRenren;

//draft
-(void)SaveSketch:(int)state;
-(BOOL)GetSketch:(BOOL)isread;

//self
-(void)ShowUploadPageCtrl;
-(void)DidShow;
-(void)HiddenUploadPageCtrl;
-(void)DidUploadFinished;

//imageselector
-(void)DidImageSelectorSelected:(id)index;

@end
